package com.edais.dao;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.edais.domain.LootShare;
import com.edais.domain.RateRisesCoupons;
import com.edais.domain.UserSign;
import com.edais.persistence.RateRisesCouponsMapper;

@Repository

public class RateRisesCouponsDao {
	@Autowired
	private RateRisesCouponsMapper rateRisesCouponsMapper;
	/**
	 * 根据参数查询我的加息券列表
	 * @param paramsMap
	 * @return
	 */
	public List<RateRisesCoupons> queryRateRisesCouponsListByParams(Map<String,Object> paramsMap){
		return rateRisesCouponsMapper.queryRateRisesCouponsListByParams(paramsMap);
	}
	
	public int queryRateRisesCouponsListByParamsCount(Map<String,Object> paramsMap){
		return rateRisesCouponsMapper.queryRateRisesCouponsListByParamsCount(paramsMap);
	}
	
	/**
	 * 获取加息券
	 * @param rateRisesCoupons
	 */
	public void insertRateRisesCoupons(RateRisesCoupons rateRisesCoupons){
		if(rateRisesCoupons==null){
			rateRisesCoupons=new RateRisesCoupons();
		}
		if(rateRisesCoupons.getRemanDays()==null){
			rateRisesCoupons.setRemanDays(0);
		}
		this.rateRisesCouponsMapper.insertRateRisesCoupons(rateRisesCoupons);
	}
	/**
	 * 获取参数列表
	 * @param listStr
	 * @return
	 * @throws Exception
	 */
	public List queryParamName(List<String> listStr) throws Exception {
		return rateRisesCouponsMapper.queryParamName(listStr);
	}

	/**
	 * 根据获取途径查询每日获取的加息券
	 * @param paramsMap
	 * @return
	 */
	public List<RateRisesCoupons> getTodayRateRisesCouponsByGetway(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.getTodayRateRisesCouponsByGetway(paramsMap);
	}
	
	public int getTodayRateRisesCouponsByGetwayCount(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.getTodayRateRisesCouponsByGetwayCount(paramsMap);
	}
	
	/**
	 * 根据id数组获取List
	 * @param rateIdsArray
	 * @return
	 */
	public List<RateRisesCoupons> getRateRisesListByRateIds(String [] rateIdsArray){
		return this.rateRisesCouponsMapper.getRateRisesListByRateIds(rateIdsArray);
	}
	/**
	 * 根据订单ID获取加息券List
	 * @param paramsMap
	 * @return
	 */
	public List<RateRisesCoupons> getRateRisesCouponsListByOrderId(Map<String,Object> paramsMap){
		return  this.rateRisesCouponsMapper.getRateRisesCouponsListByOrderId(paramsMap);
	}
	/**
	 * 更新加息券信息
	 * @param coupons
	 */
	public void updateRateRisesCouponsInfo(RateRisesCoupons coupons){
		this.rateRisesCouponsMapper.updateRateRisesCouponsInfo(coupons);
	}
	
	/**
	 * 查询用户分享信息
	 * @param paramsMap
	 * @return
	 */
	public LootShare selectLootShareInfoByParams(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.selectLootShareInfoByParams(paramsMap);
	}
	
	/**
	 * 增加用户分享信息
	 * @param lootShare
	 */
	public void insertLootShare(LootShare lootShare){
		this.rateRisesCouponsMapper.insertLootShare(lootShare);
	}
	
	/**
	 * 根据分享人手机号查询抢券人信息
	 * @param paramsMap
	 * @return
	 */
	public List<LootShare> queryLootShareInfoByShareMobile(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.queryLootShareInfoByShareMobile(paramsMap);
	}
	
	public LootShare selectShareInfoByParams(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.selectShareInfoByParams(paramsMap);
	}

	/**
	 * 查询当日分享和被查看分享获取的加息券总数
	 * @param paramsMap
	 * @return
	 */
	public  Integer selectTodayShareGetCouponsCount(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.selectTodayShareGetCouponsCount(paramsMap);
	}
	
	/**
	 * 根据订单ID查询所有使用的加息券列表
	 * @param paramsMap
	 * @return
	 */
	public List<RateRisesCoupons> getAllRateRisesCouponsListByOrderId(Map<String,Object> paramsMap){
		return  this.rateRisesCouponsMapper.getAllRateRisesCouponsListByOrderId(paramsMap);
	}
	
	/**
	 * 根据微信标识查询用户是否重复获取加息券
	 * @param paramsMap
	 * @return
	 */
	public LootShare queryLootShareInfoByWeixinOpenId(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.queryLootShareInfoByWeixinOpenId(paramsMap);
	}
	/**
	 * 查询当日分享获取加息券的总利率
	 * @param paramsMap
	 * @return
	 */
	public BigDecimal selectTodayShareGetCouponsRateRises(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.selectTodayShareGetCouponsRateRises(paramsMap);
	}
	
	/**
	 * 获取当日加息总利率
	 * @param paramsMap
	 * @return
	 */
	public BigDecimal queryCurrentRateRiseByOrderId(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.queryCurrentRateRiseByOrderId(paramsMap);
	}
	
	/**
	 * 查询用户当日签到信息
	 * @param paramsMap
	 * @return
	 */
	public UserSign queryUserCurrentSign(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.queryUserCurrentSign(paramsMap);
	}
	
	/**
	 * 增加签到信息
	 * @param userSign
	 */
	public void addUserSignInfo(UserSign userSign){
		this.rateRisesCouponsMapper.addUserSignInfo(userSign);
	}
	
	/**
	 * 更新签到信息
	 * @param userSign
	 */
	public int updateUserSignInfo(UserSign userSign){
		return this.rateRisesCouponsMapper.updateUserSignInfo(userSign);
	}
	
	/**
	 *  查询活动文案
	 * @param name
	 * @return
	 */
	public String queryTextSettingByName(String name){
		return this.rateRisesCouponsMapper.queryTextSettingByName(name);
	}
	
	/**
	 * 查询用户所有加息信息
	 * @param paramsMap
	 * @return
	 */
	public List<UserSign> queryUserSignList(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.queryUserSignList(paramsMap);
	}
	/**
	 * 获取签到加息利率
	 * @param paramsMap
	 * @return
	 */
	public BigDecimal queryQdRateRiseByOrderId(Map<String, Object> queryCoreMap) {
		// TODO Auto-generated method stub
		return this.rateRisesCouponsMapper.queryQdRateRiseByOrderId(queryCoreMap);
	}
	
	/**
	 * 查询用户当月签到信息
	 * @param paramsMap
	 * @return
	 */
	public UserSign queryUserCurrentMonthSign(Map<String,Object> paramsMap){
		return this.rateRisesCouponsMapper.queryUserCurrentMonthSign(paramsMap);
	}
}
